/* create by fillbag at 2009-03-24 */

function filterNavigateBar(){
	if (!document.getElementById) return false;
	if (!document.getElementsByTagName) return false;
	var nbar = document.getElementById('nav_bar');
	var bars = nbar.getElementsByTagName('a');
	for (var i=0; i<bars.length; i++) {
		//if (bars[i].getAttribute("class") == "popup") {
		  bars[i].onclick = function() {
		    framesUp(this.getAttribute("href"));
		    return false;
		  }
		//}
	}
	return false;
}

function framesUp(haystack){
	var fs = haystack.split(',');
	if(fs[0]){
		parent.frames['frame_menu'].location.href = fs[0];
	}	
	if(fs[1]){	
	    parent.frames['frame_details'].location.href = fs[1];
	}	
}

function toggleCollapseExpand(obj)
{
	if (obj.tagName.toLowerCase() == 'div' && obj.className == 'subhead' && obj.id != 'logout')
	{
		var display = document.getElementById('sm_main_'+obj.id).style.display;
		document.getElementById('sm_main_'+obj.id).style.display = (display=='none' ? 'block' : 'none');
	}
}

function filterTouchMenu(){
	if (!document.getElementById) return false;
	if (!document.getElementsByTagName) return false;
	var m_list = document.getElementById('menu-list');
	var m_touchs = m_list.getElementsByTagName('li');
	for (var i=0; i<m_touchs.length; i++) {
		  m_touchs[i].onmouseover = function() {
				changeStyle(this, 'over');
				return false;
		  }
		  m_touchs[i].onmouseout = function() {
				changeStyle(this, 'out');
				return false;
		  }
	}
	return false;
}

function changeStyle(objLi, strAction){
	switch(strAction)
	{
		case 'over':
			objLi.style.background = '#48CD2B';
			objLi.style.cursor = 'pointer';
			break;
		case 'out':
			objLi.style.background = '#e6e6e6';
			break;
	}
}
		
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

function modalDialog(url, name, width, height){
	if (width == undefined){
		width = 400;
	}
	if (height == undefined){
		height = 300;
	}
	
	if (window.showModalDialog){
		window.showModalDialog(url, name, 'dialogWidth=' + (width) + 'px; dialogHeight=' + (height+5) + 'px; status=off');
	}else{
		x = (window.screen.width - width) / 2;
		y = (window.screen.height - height) / 2;
	
		window.open(url, name, 'height='+height+', width='+width+', left='+x+', top='+y+', toolbar=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, modal=yes');
	}
}

function ShowToDoList(){
	try	{
		var mainFrame = window.top.frames['frame_details'];
		mainFrame.window.showTodoList(adminId);
	}catch (ex){
		
	}
}


























var url = location.href.substring((location.href.lastIndexOf("/")) + 1);
if(url.replace(/^\s*|\s*$/g, "").length != 0){
    var reg_url = /index\.php\?act=top/g;
	if(reg_url.exec(url)){
		addLoadEvent(filterNavigateBar);
	}	
	
	var menu_regexp = /index\.php\?act=menu/g;
	if(menu_regexp.exec(url)){
		document.getElementById('menu-list').onclick = function(e){
			  var obj = Utils.srcElement(e);
			  toggleCollapseExpand(obj);
		}
		addLoadEvent(filterTouchMenu);
	}
}